home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18430 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: dispatch.news.demon.net!demon!alma.ipso.net
  2. From: martin@ipso.net (Martin Barry)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: question in c++
  5. Date: Sat, 20 Apr 1996 13:13:26 GMT
  6. Message-ID: <3178e02c.167686891@news.ipso.net>
  7. References: <4l9gs9$4jp@ustsu10.ust.hk>
  8. Reply-To: martin@ipso.net
  9. NNTP-Posting-Host: alma.ipso.net
  10. X-NNTP-Posting-Host: alma.ipso.net
  11. X-Newsreader: Forte Agent .99e/32.201
  12.  
  13. hello all
  14.  
  15. i'm new to this newsgroup, and i'm a bit rusty - in fact i am
  16. re-learning C++ right now; however, i thought i'd look at this...
  17.  
  18. ec_wsk@uxmail.ust.hk (Wong Siu Ki) wrote:
  19.  
  20. :  It won't execute the cin in the while loop, how can I solve it?
  21. how do you mean?
  22. will it compile?
  23. in little problems like this, i would add the lines as follows
  24. :  
  25. :  #include <iostream.h>
  26. :  #include <stdio.h>
  27.    #define    test    0
  28. :  
  29. :  void main()
  30. :  {
  31. :    int x;        //initialise x?  will the array make sense other wise?
  32. x=0;
  33. :    char command;
  34. :    int data[500];
  35. :    int temp;
  36. :    while (scanf("%d", &temp)!=EOF)
  37. :    {
  38. :      x++;
  39. :      data[x]=temp;
  40. :    }
  41. :  
  42. :    while (command!='e')
  43. :    {
  44. :      cout << "Enter command:";
  45.     if (test=0)
  46.         cout << "here1";
  47. :      cin >> command;
  48.     if (test=0)
  49.         cout << "here2";
  50. :      cout << "test" << endl;
  51. :    }
  52. :  
  53. :  }
  54.  
  55. it will at least help in the future - when you've got mega large
  56. programs, you can't go putting in test statements and then deleting
  57. them......
  58.  
  59. i guess anything helps...
  60.  
  61. llp
  62.  
  63.  
  64. baz
  65.  
  66.  
  67.